<?php
class IdustriesController extends AppController {

	public  $name = 'Idustries';

	public function admin_index() {
		$this->Classify->recursive = 0;
		$this->set('classifies', $this->paginate());
	}
	public function admin_add() {
		if (!empty($this->data)) {
			$this->Classify->create();
			if ($this->Classify->save($this->data)) {
				$this->Session->setFlash(__('The classify has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The classify could not be saved. Please, try again.', true));
			}
		}
		$parentClassifies = $this->Classify->ParentClassify->find('list');
		$this->set(compact('parentClassifies'));
	}

	public function admin_edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid classify', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Classify->save($this->data)) {
				$this->Session->setFlash(__('The classify has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The classify could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Classify->read(null, $id);
		}
		$parentClassifies = $this->Classify->ParentClassify->find('list');
		$this->set(compact('parentClassifies'));
	}

	public function admin_delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for classify', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Classify->delete($id)) {
			$this->Session->setFlash(__('Classify deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Classify was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>